<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        

        //原型实现继承
        //借用构造函数实现继承
        
        // 组合继承：原型继承 + 借用构造函数继承

        function Person(name,age,sex){
            this.name = name
            this.age = age
            this.sex = sex
        }

        Person.prototype.sayHi = function(){
            console.log('奥利哈赛哟')
        }

        function Student(name,age,sex,score){
            Person.call(this,name,age,sex)
            this.score = score
        }
        Student.prototype = new Person()
        Student.prototype.eat = function(){
            console.log('吃东西')
        }


        var stu  = new Student('小黑',20,'男','100')
        console.log(stu.name,stu.sex,stu.age,stu.score)
        stu.sayHi()
        stu.eat()

          var stu2  = new Student('小黑黑',200,'女','200')
        console.log(stu2.name,stu2.sex,stu2.age,stu2.score)
        stu2.sayHi()
        stu2.eat()

</script>
</body>
</html>